SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
Alter Procedure [dbo].[spEditBan](@temp int, @maBan int,@tenBan string(50), @maKhu int, @maLoaiBan int, @tinhTrang int)
As
Begin
	If @temp = 0
		Delete From Ban
		Where MaBan = @maBan
	Else
		Begin
			If @maBan = 0
			Insert Into Ban
			(
				MaBan,
				TenBan,
				MaKhu,
				MaLoaiBan,
				TinhTrang
			)
			Values
			(	
				@maBan,
				@tenBan,
				@maKhu,
				@maLoaiBan,
				@tinhTrang
			)
			Else
				Update Ban
				Set
					TenBan = @tenban,
					MaKhu = @maKhu,
					MaLoaiBan = @maLoaiBan,
					TinhTrang = @tinhTrang
				Where MaBan = @maBan
		End
End